/**
 * 
 */
package org.softTank.BC.entity.services;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import org.softTank.BC.entity.IdEntity;

/**
 * @author Yuzone
 *
 */
@Entity
@Table(name = "SSDB_OPERATION")
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
public class Operation extends IdEntity {

	private String name;
	private String namespace;
	private String location;
	private String description;
	private MessageType input;
	private MessageType output;
	private MessageType fault;
	private PortType portType;

	@Column(nullable = false)
	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	@Column(nullable = false)
	public String getNamespace() {
		return namespace;
	}

	public void setNamespace(String namespace) {
		this.namespace = namespace;
	}

	@Column(nullable = false)
	public String getLocation() {
		return location;
	}

	public void setLocation(String location) {
		this.location = location;
	}

	@Column
	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	@ManyToOne(cascade = CascadeType.PERSIST, targetEntity = MessageType.class, fetch = FetchType.EAGER)
	@JoinColumn(name = "INPUT")
	public MessageType getInput() {
		return input;
	}

	public void setInput(MessageType input) {
		this.input = input;
	}

	@ManyToOne(cascade = CascadeType.PERSIST, targetEntity = MessageType.class)
	@JoinColumn(name = "OUTPUT")
	public MessageType getOutput() {
		return output;
	}

	public void setOutput(MessageType output) {
		this.output = output;
	}

	@ManyToOne(cascade = CascadeType.PERSIST, targetEntity = MessageType.class)
	@JoinColumn(name = "FAULT")
	public MessageType getFault() {
		return fault;
	}

	public void setFault(MessageType fault) {
		this.fault = fault;
	}

	@ManyToOne(cascade = CascadeType.PERSIST)
	@JoinTable(name = "SSDB_PORTTYPE_OPERATION", joinColumns = { @JoinColumn(name = "OPERATION_ID") }, inverseJoinColumns = { @JoinColumn(name = "PORTTYPE_ID") })
	// @JoinColumn(name = "id", referencedColumnName = "OPERATION_ID")
	public PortType getPortType() {
		return portType;
	}

	public void setPortType(PortType portType) {
		this.portType = portType;
	}
}
